package com.service.atf.base.model;

import com.service.atf.base.core.ByteConvertion;
import com.luotao.devp.base.utils.ByteUtil;

/**
 * User: luotao
 * Date: 12-2-23
 * Time: 15:48:00
 * �û�����	�ַ�char(20)	ʡ����+�б���+SEQ	MP
 * �ǳ�ʱ��	Int	2000�굽���ڵĺ�����
 */
public class TFLogout extends BaseHeader implements ByteConvertion {

    private int logoutTime;

    private String token;

    public TFLogout() {
        setType((byte) '1');
        setTradeType((byte) '6');
    }

    public int getLogoutTime() {
        return logoutTime;
    }

    public void setLogoutTime(int logoutTime) {
        this.logoutTime = logoutTime;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    @Override
    public ByteConvertion byte2Object(byte[] src) {
        byte2ObjectHeader(src);
        setLogoutTime(ByteUtil.readInt(src, LEN_HEAD));
        setToken(ByteUtil.readString(src, LEN_HEAD + 4, 32));
        return this;
    }

    @Override
    public byte[] object2Byte() {
        byte[] head = object2ByteHeader();
        byte[] result = new byte[LEN_HEAD + 36];
        System.arraycopy(head, 0, result, 0, head.length);
        ByteUtil.writeInt(result, LEN_HEAD, getLogoutTime());
        ByteUtil.writeString(result, LEN_HEAD + 4, getToken(), 32);
        return result;
    }
}
